package menupopupplugin2.popup.actions;

import org.eclipse.jface.wizard.Wizard;

public class ModelLayerWizard extends Wizard {
	protected InputConnectionURLPage inputConnectionURLPage;
	protected InputPackageNamePage inputPackageNamePage;
	protected PersistentLayerChoose persistentLayerChoosePage;
	private String projectPath;

	public ModelLayerWizard(String projectPath) {
		super();
		setNeedsProgressMonitor(true);
		
		this.projectPath = projectPath.substring(0, projectPath.lastIndexOf('/'));
	}

	@Override
	public void addPages() {
		inputPackageNamePage = new InputPackageNamePage(projectPath);
		inputConnectionURLPage = new InputConnectionURLPage();
		persistentLayerChoosePage = new PersistentLayerChoose();

		addPage(inputPackageNamePage);
		addPage(persistentLayerChoosePage);
		addPage(inputConnectionURLPage);
	}

	@Override
	public boolean needsPreviousAndNextButtons() {
		return super.needsPreviousAndNextButtons();
	}

	@Override
	public boolean canFinish() {
		CustomWizardPage wizardPage = (CustomWizardPage) getContainer()
				.getCurrentPage();

		return wizardPage.isFinish();
	}

	@Override
	public boolean performFinish() {
		// Print the result to the console
		inputConnectionURLPage.transitionFromTextControl();

		return true;
	}
}